home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 45975 / 45975.xpi / components / Startup.js
Text File  |  2009-11-19  |  3KB  |  65 lines

  1. /*
  2.  * Copyright (c) 2009 Bui Viet Thanh (thanhbv@gmail.com).
  3.  *
  4.  * This file is part of clicknlearn.
  5.  *
  6.  * clicknlearn is free software: you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation, either version 3 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * clicknlearn is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with clicknlearn.  If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19.  
  20. const Cc = Components.classes;
  21. const Ci = Components.interfaces;
  22. const Cu = Components.utils;
  23.  
  24. Cu.import("resource://gre/modules/XPCOMUtils.jsm");
  25.  
  26. /**
  27.  * see: https://developer.mozilla.org/en/Observer_Notifications
  28.  */
  29. function WeaveSyncStartup() {}
  30.  
  31. WeaveSyncStartup.prototype =
  32. {
  33.     classDescription: "Weave Sync Startup",
  34.     contractID: "@clicknlearn.googlecode.com/weavesync/startup;1",
  35.     classID: Components.ID("{7799cb20-4de9-11de-8a39-0800200c9a67}"),
  36.     _xpcom_categories: [{ category: "app-startup", service: true }],
  37.  
  38.     QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
  39.  
  40.     observe: function(subject, topic, data){
  41.         switch (topic){
  42.             case "app-startup":
  43.                 let observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
  44.                 observerService.addObserver(this, "final-ui-startup", true);
  45.                 break;
  46.             case "final-ui-startup":
  47.                 //see https://developer.mozilla.org/en/Toolkit_API/extIApplication
  48.                 let Application = Components.classes["@mozilla.org/fuel/application;1"]
  49.                         .getService(Components.interfaces.fuelIApplication);
  50.                 let weaveExt = Application.extensions.get("{340c2bbc-ce74-4362-90b5-7c26312808ef}");
  51. //                let alertsService = Components.classes["@mozilla.org/alerts-service;1"]
  52. //                        .getService(Components.interfaces.nsIAlertsService);
  53. //                alertsService.showAlertNotification("chrome://mozapps/skin/downloads/downloadIcon.png",
  54. //                        "Alert title", weaveExt == null? "weaveExt == null" : weaveExt.enabled,
  55. //                        false, "", null);
  56.                 if(weaveExt == null || ! weaveExt.enabled)
  57.                     return;
  58.                 let subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
  59.                 subscriptLoader.loadSubScript("chrome://clicknlearn/content/weaveIntegration.js");
  60.                 break;
  61.         }
  62.     }
  63. };
  64. var NSGetModule = XPCOMUtils.generateNSGetModule([WeaveSyncStartup]);
  65.